/*
* @Author: smallcatX0
* @Date:   2017-08-11 18:18:01
* @Last Modified by:   smallcatX0
* @Last Modified time: 2017-08-11 22:05:35
*/

#include <stdio.h>
bool check(char *chs) {
    int k = 0;
    for(int i = 0; chs[i] != '\0'; ++i) {
        if(chs[i] == 'I')
            k++;
        if(chs[i] == 'O')
            k--;
        if(k<0) return false;
    }
    if(k == 0)  return true;
    else return false;
}
int main() {
    char a[] = "IIOOIIOO";
    printf("%d\n",check(a));
    return 0;

}